﻿using Compass.Wasm.Shared.Categories;
using Compass.Wasm.Shared.Wms;
using Zack.DomainCommons.Models;

namespace Compass.WmsService.Domain.Entities;

public record Cargo : AggregateRootEntity
{
    public string MtlNumber { get; private set; }
    public string? Description { get; private set; }
    public string? EnDescription { get; private set; }
    public Unit_e Unit { get; private set; }
    public Sbu_e Sbu { get; private set; }
    public Group_e Group { get; private set; }
    public bool Consumable { get; private set; }
    public bool Inspection { get; private set; }
    public string? Location { get; private set; }
    public double SafetyStock { get; private set; }

    public OrderingWay_e OrderingWay { get; private set; }
    public int LeadTime { get; private set; }
    public double MinimalBatch { get; private set; }
    public string? Vendors { get; private set; }
    public double AvgPrice { get; private set; }
    public double LastPrice { get; private set; }
    public string? Remarks { get; private set; }
    public string? ImageUrl { get; private set; }

    private Cargo() { }
    public Cargo(Guid id, string mtlNumber, string? description, string? enDescription, Unit_e unit, Sbu_e sbu,Group_e group,bool consumable, bool inspection, string? location, double safetyStock, OrderingWay_e orderingWay, int leadTime, double minimalBatch, string? vendors, double avgPrice, double lastPrice, string? remarks, string? imageUrl)
    {
        Id = id;
        MtlNumber= mtlNumber;
        Description = description;
        EnDescription= enDescription;
        Unit = unit;
        Sbu= sbu;
        Group=group;
        Consumable=consumable;
        Inspection=inspection;
        Location = location;
        SafetyStock = safetyStock;
        OrderingWay = orderingWay;
        LeadTime=leadTime;
        MinimalBatch = minimalBatch;
        Vendors= vendors;
        AvgPrice= avgPrice;
        LastPrice= lastPrice;
        Remarks= remarks;
        ImageUrl=imageUrl;
    }

    #region Update
    public void Update(CargoDto dto)
    {
        ChangeMtlNumber(dto.MtlNumber)
            .ChangeDescription(dto.Description)
            .ChangeEnDescription(dto.EnDescription)
            .ChangeUnit(dto.Unit)
            .ChangeSbu(dto.Sbu)
            .ChangeGroup(dto.Group)
            .ChangeConsumable(dto.Consumable)
            .ChangeInspection(dto.Inspection)
            .ChangeLocation(dto.Location)
            .ChangeSafetyStock(dto.SafetyStock)
            .ChangeOrderingWay(dto.OrderingWay)
            .ChangeLeadTime(dto.LeadTime)
            .ChangeMinimalBatch(dto.MinimalBatch)
            .ChangeVendors(dto.Vendors)
            .ChangeAvgPrice(dto.AvgPrice)
            .ChangeLastPrice(dto.LastPrice)
            .ChangeRemarks(dto.Remarks)
            .ChangeImageUrl(dto.ImageUrl);

        NotifyModified();
    }

    public Cargo ChangeMtlNumber(string mtlNumber)
    {
        MtlNumber=mtlNumber;
        return this;
    }
    public Cargo ChangeDescription(string description)
    {
        Description=description;
        return this;
    }
    public Cargo ChangeEnDescription(string? enDescription)
    {
        EnDescription=enDescription;
        return this;
    }
    public Cargo ChangeUnit(Unit_e unit)
    {
        Unit=unit;
        return this;
    }
    public Cargo ChangeSbu(Sbu_e sbu)
    {
        Sbu=sbu;
        return this;
    }
    public Cargo ChangeGroup(Group_e group)
    {
        Group=group;
        return this;
    }

    public Cargo ChangeConsumable(bool consumable)
    {
        Consumable= consumable;
        return this;
    }
    public Cargo ChangeInspection(bool inspection)
    {
        Inspection = inspection;
        return this;
    }
    public Cargo ChangeLocation(string? location)
    {
        Location=location;
        return this;
    }
    public Cargo ChangeSafetyStock(double safetyStock)
    {
        SafetyStock=safetyStock;
        return this;
    }

    public Cargo ChangeOrderingWay(OrderingWay_e orderingWay)
    {
        OrderingWay=orderingWay;
        return this;
    }
    public Cargo ChangeLeadTime(int leadTime)
    {
        LeadTime=leadTime;
        return this;
    }
    public Cargo ChangeMinimalBatch(double minimalBatch)
    {
        MinimalBatch=minimalBatch;
        return this;
    }
    public Cargo ChangeVendors(string? vendors)
    {
        Vendors=vendors;
        return this;
    }
    public Cargo ChangeAvgPrice(double avgPrice)
    {
        AvgPrice=avgPrice;
        return this;
    }
    public Cargo ChangeLastPrice(double lastPrice)
    {
        LastPrice=lastPrice;
        return this;
    }

    public Cargo ChangeRemarks(string? remarks)
    {
        Remarks=remarks;
        return this;
    }

    public Cargo ChangeImageUrl(string? imageUrl)
    {
        ImageUrl=imageUrl;
        return this;
    }
    #endregion


}